/*
Created By VietRise on 21/6/2014
*/

#include "Button.h"
#include "Scenes\ScreenStart.h"
#include "Scenes\ScreenHelp.h"
#include "Scenes\ScreenInfomation.h"

Button::~Button()
{
	CC_SAFE_RELEASE(_moveIn);
	CC_SAFE_RELEASE(_moveOut);
	CC_SAFE_RELEASE(_moveInOut);
}

Button::Button(ScreenStart* game, TYPEBUTTON type)
{
	_game = game;
	_type = type;
	_state = STATEBUTTON::sNormal;
	_touch = NULL;

	switch (_type)
	{
	case btnHelp:
		this->initWithSpriteFrameName("btn_help_01.png");
		break;
	case btnLike:
		this->initWithSpriteFrameName("btn_like_01.png");
		break;
	case btnInfo:
		this->initWithSpriteFrameName("btn_info_01.png");
		break;
	case btnMusicNormal:
		this->initWithSpriteFrameName("btn_music_normal_01.png");
		break;
	case btnMusicPress:
		this->initWithSpriteFrameName("btn_music_press_01.png");
		break;
	default:
		break;
	}

	createAction();
}

Button* Button::create(ScreenStart* game, TYPEBUTTON type)
{
	Button* sprite = new Button(game, type);
	if (sprite)
	{
		sprite->autorelease();
		return sprite;
	}

	CC_SAFE_DELETE(sprite);
	return NULL;
}

void Button::createAction()
{
	CCAnimation* animation;
	CCSpriteFrame* frame;
	CCAnimate* animate;
	// Action MoveIn
	if (_type == TYPEBUTTON::btnHelp)
	{
		// Create animation button Help MoveIn
		animation = CCAnimation::create();
		for (int i = 1; i <= 5; i++)
		{
			char szName[100] = { 0 };
			sprintf(szName, "btn_help_0%i.png", i);
			frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(szName);
			animation->addSpriteFrame(frame);
		}
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEIN / 5);
		animation->setRestoreOriginalFrame(true);
		animate = CCAnimate::create(animation);
		_moveIn = CCSequence::create(animate, 
			CCCallFunc::create(this, callfunc_selector(Button::setStatePress)), 
			NULL);
		_moveIn->retain();

		// Create animation button Help MoveOut
		animation = CCAnimation::create();
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_01.png");
		animation->addSpriteFrame(frame);
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEOUT / 14);
		animation->setRestoreOriginalFrame(true);
		_moveOut = CCAnimate::create(animation);
		_moveOut->retain();

		// Create animation button Help MoveInOut
		_moveInOut = CCSequence::create(CCCallFunc::create(this, callfunc_selector(Button::setStatePress)),
										(CCAnimate*)_moveIn,
										CCCallFunc::create(this, callfunc_selector(Button::setStateOut)),
										(CCAnimate*)_moveOut, 
										CCCallFunc::create(this, callfunc_selector(Button::setStateNormal)),
										NULL);
		_moveInOut->retain();
	}
	else if (_type == TYPEBUTTON::btnLike)
	{
		// Create animation button Like MoveIn
		animation = CCAnimation::create();
		for (int i = 1; i <= 5; i++)
		{
			char szName[100] = { 0 };
			sprintf(szName, "btn_like_0%i.png", i);
			frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(szName);
			animation->addSpriteFrame(frame);
		}
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEIN / 5);
		animation->setRestoreOriginalFrame(true);
		animate = CCAnimate::create(animation);
		_moveIn = CCSequence::create(animate,
									CCCallFunc::create(this, callfunc_selector(Button::setStatePress)),
									NULL);
		_moveIn->retain();

		// Create animation button Like MoveOut
		animation = CCAnimation::create();
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_01.png");
		animation->addSpriteFrame(frame);
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEOUT / 14);
		animation->setRestoreOriginalFrame(true);
		_moveOut = CCAnimate::create(animation);
		_moveOut->retain();

		// Create animation button Like MoveInOut
		_moveInOut = CCSequence::create(CCCallFunc::create(this, callfunc_selector(Button::setStatePress)),
			(CCAnimate*)_moveIn,
			CCCallFunc::create(this, callfunc_selector(Button::setStateOut)),
			(CCAnimate*)_moveOut,
			CCCallFunc::create(this, callfunc_selector(Button::setStateNormal)),
			NULL);
		_moveInOut->retain();
	}
	else if (_type == TYPEBUTTON::btnInfo)
	{
		// Create animation button Info MoveIn
		animation = CCAnimation::create();
		for (int i = 1; i <= 5; i++)
		{
			char szName[100] = { 0 };
			sprintf(szName, "btn_info_0%i.png", i);
			frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(szName);
			animation->addSpriteFrame(frame);
		}
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEIN / 5);
		animation->setRestoreOriginalFrame(true);
		animate = CCAnimate::create(animation);
		_moveIn = CCSequence::create(animate,
			CCCallFunc::create(this, callfunc_selector(Button::setStatePress)),
			NULL);
		_moveIn->retain();

		// Create animation button Info MoveOut
		animation = CCAnimation::create();
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_01.png");
		animation->addSpriteFrame(frame);
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEOUT / 14);
		animation->setRestoreOriginalFrame(true);
		_moveOut = CCAnimate::create(animation);
		_moveOut->retain();

		// Create animation button Info MoveInOut
		_moveInOut = CCSequence::create(CCCallFunc::create(this, callfunc_selector(Button::setStatePress)),
			(CCAnimate*)_moveIn,
			CCCallFunc::create(this, callfunc_selector(Button::setStateOut)),
			(CCAnimate*)_moveOut,
			CCCallFunc::create(this, callfunc_selector(Button::setStateNormal)),
			NULL);
		_moveInOut->retain();
	}
	else if (_type == TYPEBUTTON::btnMusicNormal)
	{
		// Create animation button MusicNormal MoveIn
		animation = CCAnimation::create();
		for (int i = 1; i <= 5; i++)
		{
			char szName[100] = { 0 };
			sprintf(szName, "btn_music_normal_0%i.png", i);
			frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(szName);
			animation->addSpriteFrame(frame);
		}
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEIN / 5);
		animation->setRestoreOriginalFrame(true);
		animate = CCAnimate::create(animation);
		_moveIn = CCSequence::create(animate,
			CCCallFunc::create(this, callfunc_selector(Button::setStatePress)),
			NULL);
		_moveIn->retain();

		// Create animation button MusicNormal MoveOut
		animation = CCAnimation::create();
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_01.png");
		animation->addSpriteFrame(frame);
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEOUT / 14);
		animation->setRestoreOriginalFrame(true);
		_moveOut = CCAnimate::create(animation);
		_moveOut->retain();

		// Create animation button MusicNormal MoveInOut
		_moveInOut = CCSequence::create(CCCallFunc::create(this, callfunc_selector(Button::setStatePress)),
			(CCAnimate*)_moveIn,
			CCCallFunc::create(this, callfunc_selector(Button::setStateOut)),
			(CCAnimate*)_moveOut,
			CCCallFunc::create(this, callfunc_selector(Button::setStateNormal)),
			NULL);
		_moveInOut->retain();
	}
	else if (_type == TYPEBUTTON::btnMusicPress)
	{
		// Create animation button MusicPress MoveIn
		animation = CCAnimation::create();
		for (int i = 1; i <= 5; i++)
		{
			char szName[100] = { 0 };
			sprintf(szName, "btn_music_press_0%i.png", i);
			frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(szName);
			animation->addSpriteFrame(frame);
		}
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEIN / 5);
		animation->setRestoreOriginalFrame(true);
		animate = CCAnimate::create(animation);
		_moveIn = CCSequence::create(animate,
			CCCallFunc::create(this, callfunc_selector(Button::setStatePress)),
			NULL);
		_moveIn->retain();

		// Create animation button MusicPress MoveOut
		animation = CCAnimation::create();
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_04.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_01.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_03.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_02.png");
		animation->addSpriteFrame(frame);
		frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_01.png");
		animation->addSpriteFrame(frame);
		animation->setDelayPerUnit(TIME_ANIMATION_BTN_MOVEOUT / 14);
		animation->setRestoreOriginalFrame(true);
		_moveOut = CCAnimate::create(animation);
		_moveOut->retain();

		// Create animation button MusicPress MoveInOut
		_moveInOut = CCSequence::create(CCCallFunc::create(this, callfunc_selector(Button::setStatePress)),
			(CCAnimate*)_moveIn,
			CCCallFunc::create(this, callfunc_selector(Button::setStateOut)),
			(CCAnimate*)_moveOut,
			CCCallFunc::create(this, callfunc_selector(Button::setStateNormal)),
			NULL);
		_moveInOut->retain();
	}
}

void Button::moveIn()
{
	_state = STATEBUTTON::sPress;
	this->stopAllActions();
	this->runAction(_moveIn);
}

void Button::moveOut(bool replaceScreen)
{
	_state = STATEBUTTON::sOut;
	this->stopAllActions();
	if (replaceScreen)
	{
		this->runAction(CCSequence::create((CCAnimate*)_moveOut,
						CCCallFuncN::create(this, callfuncN_selector(Button::replaceScreen)),
						NULL));
	}	
	else
	{
		this->runAction(CCSequence::create((CCAnimate*)_moveOut,
						CCCallFunc::create(this, callfunc_selector(Button::setStateNormal)),
						NULL));
	}
}

void Button::moveInOut()
{
	this->stopAllActions();
	this->runAction(_moveInOut);
}

void Button::setStatePress()
{
	_state = STATEBUTTON::sPress;
	switch (_type)
	{
	case btnHelp:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_05.png"));
		break;
	case btnLike:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_05.png"));
		break;
	case btnInfo:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_05.png"));
		break;
	case btnMusicNormal:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_05.png"));
		break;
	case btnMusicPress:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_05.png"));
		break;
	default:
		break;
	}
}

void Button::setStateOut()
{
	_state = STATEBUTTON::sOut;
}

void Button::setStateNormal()
{
	_state = STATEBUTTON::sNormal;
	_touch = NULL;
	switch (_type)
	{
	case btnHelp:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_01.png"));
		break;
	case btnLike:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_01.png"));
		break;
	case btnInfo:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_01.png"));
		break;
	case btnMusicNormal:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_normal_01.png"));
		break;
	case btnMusicPress:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_music_press_01.png"));
		break;
	default:
		break;
	}
}

void Button::replaceScreen(CCNode* pSender)
{
	_state = STATEBUTTON::sNormal;
	_touch = NULL;
	CCScene* newScene;
	switch (_type)
	{
	case btnHelp:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_01.png"));
		newScene = CCTransitionMoveInR::create(0.2f, ScreenHelp::scene());
		CCDirector::sharedDirector()->replaceScene(newScene);
		break;
	case btnLike:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_like_01.png"));
		break;
	case btnInfo:
		this->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_info_01.png"));
		newScene = CCTransitionMoveInR::create(0.2f, ScreenInfomation::scene());
		CCDirector::sharedDirector()->replaceScene(newScene);
		break;
	case btnMusicNormal:
		CCUserDefault::sharedUserDefault()->setBoolForKey("music", false);

		_game->setVisiableBtnMusicPress();
		break;
	case btnMusicPress:
		CCUserDefault::sharedUserDefault()->setBoolForKey("music", true);

		_game->setVisiableBtnMusicNormal();
		break;
	default:
		break;
	}
}